package es.uji.viselab.math;

import javax.vecmath.Vector3d;
import javax.vecmath.Vector4d;

import es.uji.viselab.kinematics.TMatrix4f;

public class PointXYZ {
	private double x;
	private double y;
	private double z;

	public PointXYZ(double x2, double y2, double z2) {
		x = x2;
		y = y2;
		z = z2;
	}

	public PointXYZ() {
	}

	public PointXYZ(PointXYZ p) {
		x = p.x;
		y = p.y;
		z = p.z;
	}

	public double getX() {
		return x;
	}

	public void setX(double x) {
		this.x = x;
	}

	public double getY() {
		return y;
	}

	public void setY(double y) {
		this.y = y;
	}

	public double getZ() {
		return z;
	}

	public void setZ(double z) {
		this.z = z;
	}

	public void increase(double dx, double dy, double dz) {
		x = x + dx;
		y = y + dy;
		z = z + dz;
	}

	public PointXYZ transform(TMatrix4f tc) {
		Vector4d v4 = new Vector4d(this.x, this.y, this.z, 1);
		Vector3d v3 = new Vector3d();
		v3 = tc.mult(v4);
		this.x = v3.x;
		this.y = v3.y;
		this.z = v3.z;
		return this;
	}

	public int getXint() {
		return (int) getX();
	}

	public int getYint() {
		return (int) getY();
	}

	public int getZint() {
		return (int) getZ();
	}

	public PointXYZ substract(PointXYZ p1) {
		x = x - p1.x;
		y = y - p1.y;
		z = z - p1.z;
		return this;

	}

	public boolean equal(PointXYZ point) {
		int x = (int) (point.x - this.x);
		int y = (int) (point.y - this.y);
		int z = (int) (point.z - this.z);
		return x==0 && y==0 && z==00;
	}
}
